package com.arpa.oms.domain.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.arpa.oms.domain.enums.OrderStatusEnum;
import com.arpa.oms.domain.enums.PurchaseTypeEnum;
import com.arpa.wms.domain.entity.BasicEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * OMS采购退货单
 * </p>
 *
 * @author LEO
 * @since 2020-11-17
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="OmsPurchaseReturn对象", description="OMS采购退货单")
public class OmsPurchaseReturn extends BasicEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "采购退货单号")
    @TableField("code")
    private String code;

    @ApiModelProperty(value = "仓库code",required = true)
    @NotEmpty(message = "仓库不能为空")
    @TableField("warehouse_code")
    private String warehouseCode;

    @ApiModelProperty(value = "货主code",required = true)
    @NotEmpty(message = "货主不能为空")
    @TableField("shipment_code")
    private String shipmentCode;

    @ApiModelProperty(value = "货主名称",required = true)
    @NotEmpty(message = "货主名称不能为空")
    @TableField("shipment_name")
    private String shipmentName;

    @ApiModelProperty(value = "所属机构标识",hidden = true)
    @TableField("group_code")
    private String groupCode;

    @ApiModelProperty(value = "供应商标识",required = true)
    @NotEmpty(message = "供应商标识不能为空")
    @TableField("supplier_code")
    private String supplierCode;

    @ApiModelProperty(value = "供应商名称",required = true)
    @NotNull(message = "供应商名称不能为空")
    @TableField("supplier_name")
    private String supplierName;

    @ApiModelProperty(value = "采购单号",required = true)
    @NotEmpty(message = "采购单号不能为空")
    @TableField("source_code")
    private String sourceCode;

    @ApiModelProperty(value = "计划退货数量（退货单位）",required = true)
    @NotNull(message = "计划退货数量不能为空")
    @Digits(integer = 14,fraction = 6)
    @TableField("plan_quantity")
    private BigDecimal planQuantity;

    @ApiModelProperty(value = "计划退货数量（基本单位）",hidden = true)
    @TableField("plan_basic_quantity")
    private BigDecimal planBasicQuantity;
    @ApiModelProperty(value = "实退货购数量（退货单位）")
    @Digits(integer = 14,fraction = 6)
    @TableField("actual_quantity")
    private BigDecimal actualQuantity;

    @ApiModelProperty(value = "实际退货数量（退货单位）",hidden = true)
    @TableField("actual_basic_quantity")
    private BigDecimal actualBasicQuantity;

    @ApiModelProperty(value = "状态：新增、作废、待审核、审核通过、审核不通过",hidden = true)
    @TableField("status")
    private OrderStatusEnum status;


    @ApiModelProperty(value = "采购退货类型 PURCHASERETURNS:采购退货")
    @TableField("purchase_return_type")
    private PurchaseTypeEnum purchaseReturnType;


    @ApiModelProperty(value = "审核意见")
    @TableField("verify_opinion")
    @Length(max = 255, message = "审核意见最多输入255个字符")
    private String verifyOpinion;

    @ApiModelProperty(value = "审核时间")
    @TableField("gmt_verify")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime gmtVerify;

    @ApiModelProperty(value = "审核人")
    @TableField("verify_by")
    private String verifyBy;

    @ApiModelProperty(value = "审核人姓名")
    @TableField("verify_name")
    private String verifyName;

    @ApiModelProperty(value = "备注")
    @TableField("remarks")
    @Length(max = 100, message = "备注最多输入100个字符")
    private String remarks;



    @Valid
    @TableField(exist = false)
    private List<OmsPurchaseReturnItem> omsPurchaseReturnItemList;

}
